<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
	<base th:href="@{/}">
	<meta charset="utf-8">
	<title>新增</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="static/jquery-easyui/themes/icon.css">
	<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
	<script type="text/javascript" src="static/layui/layui.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/jquery.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="static/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="static/js/common/reportTemplet.js"></script>
	<style type="text/css">
		.layui-form-label {
			white-space: nowrap;
			width: 120px;
			color: gray;
		}
	</style>
</head>
<body class="layui-fluid" th:fragment="body">
<div class="layui-row">
	<div class="layui-col-md12">
		<form class="layui-form" action="" id="form">
			<div class="layui-form-item" style="margin-top: 20px;">
				<div class="layui-inline">
					<label class="layui-form-label">企业编码</label>
					<div class="layui-input-inline">
						<input type="text" name="cusCode" lay-verify="required"  id="cusCode" placeholder="请输入企业编码" autocomplete="off" class="layui-input" >
					</div>
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<div class="layui-inline">
					<label class="layui-form-label">企业名称</label>
					<div class="layui-input-inline">
						<input type="text" name="cusName" lay-verify="required"  id="cusName" placeholder="请输入企业名称" autocomplete="off" class="layui-input" >
					</div>
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<div class="layui-inline">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-inline">
						<input type="text" name="plaintextPwd" lay-verify="required"  id="pwd" placeholder="请输入密码" autocomplete="off" class="layui-input" >
					</div>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript" th:inline="javascript">
	layui.config({
		base: "static/layui/"
	}).extend({
		tableSelect: 'tableSelect'
	}).use(['form', 'layer', 'jquery', 'table','tableSelect'], function () {
		let form = layui.form;
		let $ = layui.jquery;
		let tableSelect = layui.tableSelect;

		form.render()

		tableSelect.render({
			elem: '#cusCode',
			checkedKey: 'cusCode',
			searchPlaceholder: '企业编码',
			searchKey: 'cusCode',
			table: {
				url: 'manage/select/getMaterialCus'
				,cols: [
					[
						{ type: 'radio' },
						{ field: 'cusCode', title: '企业编码' },
						{ field: 'cusName', title: '企业名称' },
					]
				]
			},
			done: function (elem, data) {
				let NEWJSON = []
				let NAME = []
				layui.each(data.data, function (index, item) {
					NEWJSON.push(item.cusCode)
					NAME.push(item.cusName)
				})
				elem.val(NEWJSON.join(","))
				$('#cusName').val(NAME.join(","))
			}
		})

	})
	function getFormDataAndValidate(){
		var flag = $("#form").form('enableValidation').form('validate');
		if(!flag){
			return [false,{}];
		}
		var data = $('#form').serializeArray();
		var obj = new Object();
		$.each(data, function(index, e){
			obj[e.name] = e.value;
		})
		return [true,obj];
	}
</script>
</body>
</html>